package day07.Collection;

import java.util.ArrayList;
import java.util.Iterator;

public class Lian01 {
    public static void main(String[] args) {
        ArrayList<Student>list=new ArrayList<>();
        Student s1=new Student("张三",23);
        Student s2=new Student("李四",23);
        Student s3=new Student("王二",23);
        list.add(s1);
        list.add(s2);
        list.add(s3);
        Iterator<Student> it = list.iterator();
        while (it.hasNext()){
            Student s=it.next();
            System.out.println(s);
        }
        for (Student student : list) {
            System.out.println(student);
        }
    }
}
